package hpc.exercices;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Random;

public class Utils {

	/*
	 * Method to read kernel code from external file
	 */
	public static String readFile(String path, Charset encoding)
			throws IOException {
		byte[] encoded = Files.readAllBytes(Paths.get(path));
		return new String(encoded, encoding);
	}

	/*
	 * Method to create a array with n elements and random values
	 */
	public static int[] randomArray(int n) {
		int max = 10;
		int array[] = new int[n];

		Random generator = new Random();

		for (int i = 0; i < n; i++) {
			array[i] = generator.nextInt(max)+1;
		}
		return array;
	}
}
